package com.sky.financelake.retrofit;

import androidx.lifecycle.MutableLiveData;

import com.sky.financelake.bean.dto.QuotationDto;
import com.sky.financelake.bean.dto.SimpleDayKDto;
import com.sky.financelake.bean.entity.Fundamental;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class FundamentalRepository {

    private static FundamentalRepository repository;

    public static FundamentalRepository getInstance() {
        if (repository == null) {
            repository = new FundamentalRepository();
        }
        return repository;
    }

    private Api api;

    public FundamentalRepository() {
        api = RetrofitService.cteateService(Api.class);
    }

    public void getFundamentalByCode(MutableLiveData data, String code) {
        api.getFundamentalByCode(code).enqueue(new Callback<ApiResponse<Fundamental>>() {
            @Override
            public void onResponse(Call<ApiResponse<Fundamental>> call, Response<ApiResponse<Fundamental>> response) {
                if (response.isSuccessful()) {
                    data.setValue(response.body());
                }
            }

            @Override
            public void onFailure(Call<ApiResponse<Fundamental>> call, Throwable t) {
                data.setValue(null);
            }
        });
    }

   
}
